package com.manager.core.ad.bean;

import android.text.TextUtils;
import android.util.Log;
import com.bykv.vk.openvk.CSJAdError;
import com.bykv.vk.openvk.mediation.manager.MediationAdEcpmInfo;
import yyee.llee.mmee.base_api_net.base_api_bean.NATAdInfo;
import yyee.llee.mmee.base_api_net.base_api_bean.NAdError;

public class NAdBeanCreator {

    public static NAdError createAdError(CSJAdError adError) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] quiwyieqasdad = new int[] { 12, 34, 3 };
        int asdjasdhjkah;
        // 第一层循环:表明比较的次数, 比如 length 个元素,比较次数为 length-1 次（肯定不需和自己比）
        for (int ahjdgajhsd = 0; ahjdgajhsd < quiwyieqasdad.length - 1; ahjdgajhsd++) {
            for (int uiqwyeuiqwe = quiwyieqasdad.length - 1; uiqwyeuiqwe > ahjdgajhsd; uiqwyeuiqwe--) {
                if (quiwyieqasdad[uiqwyeuiqwe] < quiwyieqasdad[uiqwyeuiqwe - 1]) {
                    asdjasdhjkah = quiwyieqasdad[uiqwyeuiqwe];
                    quiwyieqasdad[uiqwyeuiqwe] = quiwyieqasdad[uiqwyeuiqwe - 1];
                    quiwyieqasdad[uiqwyeuiqwe - 1] = asdjasdhjkah;
                }
            }
        }
        return new NAdError(adError.getCode() + "", adError.getMsg(), "" + adError.getCode(), "" + adError.getMsg());
    }

    public static NAdError createAdError(int code, String msg) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] akhsdkjahsdkjah = new int[] { 1, 2, 3 };
        for (int askjdhajkhd = 1; askjdhajkhd < akhsdkjahsdkjah.length; askjdhajkhd++) {
            int asbdhjagdjhka = akhsdkjahsdkjah[askjdhajkhd];
            int asjkdhjaksd;
            for (asjkdhjaksd = askjdhajkhd - 1; asjkdhjaksd >= 0 && asbdhjagdjhka < akhsdkjahsdkjah[asjkdhjaksd]; asjkdhjaksd--) {
                akhsdkjahsdkjah[asjkdhjaksd + 1] = akhsdkjahsdkjah[asjkdhjaksd];
            }
            akhsdkjahsdkjah[asjkdhjaksd + 1] = asbdhjagdjhka;
        }
        return new NAdError(code + "", msg, "", "");
    }

    // 穿山甲融合GrowMore
    public static NATAdInfo createNATAdInfo(MediationAdEcpmInfo mediationAdEcpm) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] zmxcbzc = new int[] { 2, 12, 34 };
        for (int jkashdkas = 0; jkashdkas < zmxcbzc.length; jkashdkas++) {
            int miniPost = jkashdkas;
            for (int zmasdadasd = jkashdkas + 1; zmasdadasd < zmxcbzc.length; zmasdadasd++) {
                if (zmxcbzc[zmasdadasd] < zmxcbzc[miniPost]) {
                    miniPost = zmasdadasd;
                }
            }
            if (zmxcbzc[jkashdkas] > zmxcbzc[miniPost]) {
                int asdadavavaqvq;
                asdadavavaqvq = zmxcbzc[jkashdkas];
                zmxcbzc[jkashdkas] = zmxcbzc[miniPost];
                zmxcbzc[miniPost] = asdadavavaqvq;
            }
        }
        NATAdInfo natAdInfo;
        if (mediationAdEcpm != null) {
            // String getSdkName() 获取SDK名称
            // getCustomSdkName() 获取自定义ADN名称
            // String getSlotId()  获取代码位ID
            // String getEcpm()  获取价格 单位是分
            // String getRitType() 获取代码位类型
            // int getReqBiddingType() 获取bidding类型
            // String getErrorMsg() 获取错误信息
            // String getRequestId() 获取请求唯一标识 广告对应的request_id,目前只有穿山甲和mintegral才有，其余返回为空
            String ecpm = mediationAdEcpm.getEcpm();
            Log.d("NAdBeanFactory", "ecpm值>> " + ecpm);
            if (TextUtils.isEmpty(ecpm)) {
                ecpm = "0";
            }
            String sdkName = mediationAdEcpm.getSdkName();
            if (TextUtils.isEmpty(sdkName)) {
                sdkName = "sdkname";
            }
            String slotId = mediationAdEcpm.getSlotId();
            if (TextUtils.isEmpty(slotId)) {
                slotId = "111111";
            }
            natAdInfo = new NATAdInfo(sdkName, slotId, Double.parseDouble(ecpm) / 100 + "", mediationAdEcpm.getReqBiddingType());
        } else {
            natAdInfo = new NATAdInfo();
        }
        return natAdInfo;
    }
}
